<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/common.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head></head>
<body class="gray-bg">

	<div class="container-div">
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
	</div>
	<script>
		var prefix = "${ctx}/toDoTask";
	
		$(function() {
			var options = {
				url : prefix + "/list/${type}",
				modalName : "待办任务",
				search : false,
				showExport : true,
				showColumns : false,
				showToggle : false,
				columns : [ {
					checkbox : true
				},
					{
						field : 'taskId',
						title : '编号',
						visible : false
					},
					{
						field : 'taskName',
						title : '任务名称',
					},
					{
						field : 'time',
						title : '发生时间',
					},
					{
						title : '操作',
						align : 'center',
						formatter : function(value, row, index) {
							var actions = [];
							actions.push('<a class="btn btn-success btn-xs" href="#" onclick="doExamine(\'' + row.taskBusinessKey + '\',\'' + row.taskType + '\',\'' + row.taskId + '\',\'' + row.taskStatus + '\')"><i class="fa fa-edit"></i>处理</a> ');
	
							//actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="doRemove(\'' + row.taskBusinessKey + '\',\'' + row.taskType + '\',\'' + row.taskId + '\')"><i class="fa fa-remove"></i>删除</a>');
	
							return actions.join('');
						}
					} ]
			};
			$.table.init(options);
		});
	
	
		function doExamine(taskBusinessKey, taskType, taskId, taskStatus) {
			if (taskType == 'taxpayer') {
				if (taskStatus == 3) {
					window.location.href = '${ctx}/system/taxpayer/edit/' + taskBusinessKey + '?taskId=' + taskId;
				} else {
					window.location.href = '${ctx}/system/taxpayer/examine/' + taskId + '/' + taskBusinessKey;
				}
			} else if (taskType == 'taxRegistration') {
				if (taskStatus == 3) {
					window.location.href = '${ctx}/system/registration/edit/' + taskBusinessKey + '?taskId=' + taskId;
				} else {
					window.location.href = '${ctx}/system/registration/examine/' + taskId + '/' + taskBusinessKey;
				}
			} else if (taskType == 'registrationInfo') {
				if (taskStatus == 3) {
					window.location.href = '${ctx}/system/info/edit/' + taskBusinessKey + '?taskId=' + taskId;
				} else {
					window.location.href = '${ctx}/system/info/examine/' + taskId + '/' + taskBusinessKey;
				}
			} else if (taskType == 'taxRegistrationChange') {
				if (taskStatus == 6) {
					window.location.href = '${ctx}/system/registration/change/' + taskBusinessKey + '?taskId=' + taskId;
				} else {
					window.location.href = '${ctx}/system/registration/examineChange/' + taskId + '/' + taskBusinessKey;
				}
			} else if (taskType == 'invoiceApply') {
				if (taskStatus == 3) {
					window.location.href = '${ctx}/system/apply/edit/' + taskBusinessKey + '?taskId=' + taskId;
				} else {
					window.location.href = '${ctx}/system/apply/examine/' + taskId + '/' + taskBusinessKey;
				}
			} else if (taskType == 'taxDeclaration') {
				if (taskStatus == 3) {
					window.location.href = '${ctx}/system/declaration/edit/' + taskBusinessKey + '?taskId=' + taskId;
				} else {
					window.location.href = '${ctx}/system/declaration/examine/' + taskId + '/' + taskBusinessKey;
				}
			} else if (taskType == 'taxRegistrationDelete') {
				window.location.href = '${ctx}/system/registration/examine/' + taskId + '/' + taskBusinessKey+'?type=delete';
			}
		}
	
		function doRemove(taskBusinessKey, taskType, taskId) {
			var url = "";
			if (taskType == 'taxpayer') {
				url = '${ctx}/system/taxpayer/remove';
	
			}
			$.post(url, {
				ids : taskBusinessKey
			}, function(data, status) {
				if (data.code == 0) {
					alert("删除成功");
					window.location.href = '${ctx}/toDoTask/list/${type}';
				}
			});
		}
	</script>
</body>
</html>